<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="box"></div>
    <script>
      //       let m = 2;
      //     let reg = /1m 3/;

      //   let n = `1${m} 3`;
      //   let reg = new RegExp(n,'gim');
      //   let str = "45612 3789";
      //   let res = reg.test(str);
      //   console.log(res);

      //   let reg = /\\d/;
      //   let reg = /\\d/gim;
      //   let str = "\\d";
      //   console.log(str);
      //   console.log(reg.test(str));
      // let str = `aaaaabcaa啊d a aaaa萨达a人人c`;
      // let reg = /[\u4e00-\u9fa5]/g;
      // let res = str.split(reg);
      // console.log(res);
      // `var str = "高高兴兴";
      // console.log(/([\u4e00-\u9fa5]{1})\1([\u4e00-\u9fa5]{1})\2/g.test(str));`
      //把 "Doe, John" 转换为 "John Doe" 的形式：
      // var str = "Doe       , John";
      // let res = str.replace(/(\w+)\s*,\s*(\w+)/, "$2 , $1");
      // console.log(res);
      //说明：$1,$2上就是按顺序对应小括号里面的小正则 捕获到的内容。

      // let str = "foo";
      // var reg = /foo/g;
      // console.log(reg.lastIndex);
      // console.log(reg.test("foo")); //true
      // console.log(reg.lastIndex);
      // console.log(reg.test("foo")); //false
      // console.log(reg.test("foo")); //true
      // console.log(reg.test("foo")); //true
      // console.log(reg.test("foo")); //false
      // console.log(reg.test("foo")); //true
      // console.log(reg.test("foo")); //true
      // console.log(reg.test("foo")); //false
      // console.log(reg.test("foo")); //true
      let reg = /^\d+$/g;
      str = 123;
      reg =
        /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/;
      console.log(reg.test(str));
    </script>
  </body>
</html>
